package com.faiz.algorithm;

import java.util.Arrays;

public class MaxAscSequence {

    /**
     * dp[i]表示[0,i]个元素中的最大子序列
     *
     * @param nums
     * @return
     */
    public static int maxAscSeq(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);
        for (int i = 0; i < nums.length; i++) {
            int tmp = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    tmp = Math.max(tmp, dp[j] + 1);
                } else {
                    tmp = Math.max(tmp, dp[j]);
                }

            }
            dp[i] = tmp;
        }
        return dp[nums.length - 1];
    }

    public static void main(String[] args) {
        int[] nums = {2, 4, 1, 5, 5, 6};
        System.out.println(maxAscSeq(nums));
    }
}
